﻿IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[fn_ReformatStatement]'))
DROP FUNCTION [dbo].[fn_ReformatStatement]
GO

CREATE FUNCTION [dbo].[fn_ReformatStatement](
	@Value NVARCHAR(MAX)
)
RETURNS NVARCHAR(MAX)
AS
BEGIN
	IF(@Value IS NOT NULL)
	BEGIN
		SET @Value = RTRIM(LTRIM(@Value));
		SET @Value = REPLACE(@Value,'--','');
		SET @Value = REPLACE(@Value,'''','');
		SET @Value = REPLACE(@Value,'"','');
		SET @Value = REPLACE(@Value,',','');
		SET @Value = REPLACE(@Value,';','');
		SET @Value = REPLACE(@Value,'/','');
		SET @Value = REPLACE(@Value,'\','');
	END

	RETURN @Value;
END
GO